package cn.ld.module.ai.dal.mapper.model;

import cn.ld.framework.common.pojo.PageResult;
import cn.ld.framework.mybatis.core.mapper.BaseMapperX;
import cn.ld.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.ld.framework.mybatis.core.query.QueryWrapperX;
import cn.ld.module.ai.controller.admin.model.vo.chatModel.AiChatModelPageInVO;
import cn.ld.module.ai.dal.entity.model.AiChatModelEntity;
import org.apache.ibatis.annotations.Mapper;

import java.util.Collection;
import java.util.List;

/**
 * API 聊天模型 Mapper
 *
 * @author fansili
 */
@Mapper
public interface AiChatModelMapper extends BaseMapperX<AiChatModelEntity> {

    default AiChatModelEntity selectFirstByStatus(Integer status) {
        return selectOne(new QueryWrapperX<AiChatModelEntity>()
                .eq("status", status)
                .limitN(1)
                .orderByAsc("sort"));
    }

    default PageResult<AiChatModelEntity> selectPage(AiChatModelPageInVO inVO) {
        return selectPage(inVO, new LambdaQueryWrapperX<AiChatModelEntity>()
                .likeIfPresent(AiChatModelEntity::getName, inVO.getName())
                .eqIfPresent(AiChatModelEntity::getModel, inVO.getModel())
                .eqIfPresent(AiChatModelEntity::getPlatform, inVO.getPlatform())
                .orderByAsc(AiChatModelEntity::getSort));
    }

    default List<AiChatModelEntity> selectList(Integer status) {
        return selectList(new LambdaQueryWrapperX<AiChatModelEntity>()
                .eq(AiChatModelEntity::getStatus, status)
                .orderByAsc(AiChatModelEntity::getSort));
    }

}
